<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        () => {} //箭头函数
        //传统的函数求和
        function sum(x, y) {
            console.log(x + y);
        }
        sum(1, 2);

        const fn = (a, b) => {
            console.log(a + b);
        }
        fn(1, 5);

        // 当形参和代码只有一句或者一个 可以简写
        const ff = (s, b) => s + b; //省略了return
        console.log(ff(5, 4));


        const fb = value => value;
        console.log(fb(2));



        // 箭头函数没有自己的this，她的this是继承父级的父级this 暂时这样理解把
        var name = "xiaoming";
        const objjj = {
            name: 'xiaofang',
            o: this,
            say: () => {
                // console.log(this); //指向的是window 继承自say的父级的父级objjj的this
                console.log(this.name);
            },
            hellow: function() {
                // console.log(this); //指向obj
                let fn = () => {
                    console.log(this); //指向的是obj  继承自父级的父级this
                    console.log(this.name);
                }
                return fn()

            }
        }
        objjj.say();
        console.log(objjj.o);
        objjj.hellow();
        // (function() {
        //     console.log(this);
        // }())
    </script>
</body>

</html>